﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows;
using Caliburn.Micro;
using OPSYS_Schematic.UIInfrastructure;

namespace OPSYS_Schematic.Presentation.Parts
{
    [Export(typeof (ITheme))]
    [MenuPart(BaseMenu = WorkbenchName.ThemePart, NextMenu = WorkbenchName.ExpressionDarkThemePart)]
    public class DefaultTheme : MenuPart, ITheme
    {
        private IEnumerable<ResourceDictionary> resources;

        public DefaultTheme()
            : base(WorkbenchName.DefaultThemePart)
        {
            IsCheckable = true;
        }

        #region ITheme Members

        public IEnumerable<ResourceDictionary> Resources
        {
            get
            {
                if (resources == null)
                {
                    resources = new[]
                                    {
                                        this.LoadResourceDictionary(new Uri("Themes/aero.normalcolor.xaml",
                                                                            UriKind.Relative))
                                    };
                }
                return resources;
            }
        }

        #endregion

        public override void Execute()
        {
            IoC.Get<IThemeService>().ChangeTheme(this);
        }
    }
}